package cn.edu.abtu.servlet;

import cn.edu.abtu.pojo.Student;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

public class StudentInfoServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
       doPost(req, resp);
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
       req.setCharacterEncoding("UTF-8");
       resp.setCharacterEncoding("UTF-8");
       //获取前台数据
        String stuNo=req.getParameter("stuNo");
        String stuName=req.getParameter("stuName");
        String school=req.getParameter("school");
        //生成Student对象，模拟从数据库中根据字号查找对象
        Student stu=new Student();
        stu.setId(1);
        stu.setStuNo(stuNo);
        stu.setStuName(stuName);
        stu.setSchool(school);
        req.setAttribute("student",stu);
        req.getRequestDispatcher("/StudentSecondServlet").forward(req,resp);
    }
}
